#pragma once

#include "IRenderer.h"

class OpenGLRenderer : public IRenderer
{
public:
	Pointer<IWindow> Initialize();
	void Deinitialize();
	// Window Functions
	bool ResizeWindow( IEvent& event );
	bool CreateDeviceContext();
	void DestroyDeviceContext();
	bool CreateRenderContext();
	void DestroyRenderContext();
	bool MakeContextCurrent();
	// Renderer Functions
	void SetShader( const HashedString& shader );
	void UnsetShader();
	void SetColor( unsigned char r, unsigned char g, unsigned char b, unsigned char a );
	void SetColor( unsigned int color );
	void SetMaterial( const Material& material );
	void UnsetMaterial();
	void PushTexture( const HashedString& texture );
	void PopTexture();
	void SetUniforms( const HashedString& shaderName, const UniformCountLocationMap_t& uniforms ) const;
	void EnableLight( const Light& light );
	void DisableLight( const Light& light );
	void Render( const IVertexContainer& container );
	void SwapBuffer();
	void ClearBuffer();
	void SetUniform( const HashedString& shaderName, const HashedString&  uniformName, int elements, float* data, bool transpose ) const;
	// Create Functions
	void CreateShaderSource( const HashedString& sourceName, std::vector <const char*> source, unsigned int shaderType );
	void CreateShader( const HashedString& shaderName, std::vector<HashedString> sourceNames );
	void FreeShaderSource( const HashedString& sourceName );
	void FreeShader( const HashedString& shaderName );
	void LinkUniform( const HashedString& shaderName, const HashedString& uniformName, Shader::UniformType type );
	void LinkAttribute( const HashedString& shaderName, const HashedString& attributeName, Shader::UniformType type );
	void LoadTexture( HashedString& name, Texture& texture, bool freeImage );
	
	void BuildFont( const HashedString& fontName, unsigned int height, unsigned int width = 0, int angleOfEscape = 0, int orientAngle = 0, unsigned int weight = 0x700, bool italics = false, bool underline = false, bool strikeout = false);
	void FreeFont( const HashedString& fontName );
	void PrintFont( const HashedString& fontName, unsigned int color, int x, int y, const char* fmt, ... );
protected:
	void* m_windowHandle;
	void* m_device;
	void* m_renderer;
public:
 	OpenGLRenderer(void);
	virtual ~OpenGLRenderer(void);
	void* operator new( size_t size );

};